﻿@using Utility = BootstrapBlazor.Shared.Samples.Charts.Utility

<Chart ChartType="ChartType.Doughnut" OnInitAsync="@OnInit" Height="400px" Width="400px" />

@code {
    private Random Randomer { get; } = new();

    private int DoughnutDatasetCount = 1;

    private int DoughnutDataCount = 5;

    private Task<ChartDataSource> OnInit()
    {
        var ds = new ChartDataSource();
        ds.Options.Title = "Doughnut Donut Chart";
        ds.Labels = Utility.Colors.Take(DoughnutDataCount);
        for (var index = 0; index < DoughnutDatasetCount; index++)
        {
            ds.Data.Add(new ChartDataset()
            {
                Label = $"Set {index}",
                Data = Enumerable.Range(1, DoughnutDataCount).Select(i => Randomer.Next(20, 37)).Cast<object>()
            });
        }
        return Task.FromResult(ds);
    }
}
